import base64
from typing import List

import shortuuid
from peewee import JOIN

from afast_core.core_libs.captcha.cilent import generate_captcha
from afast_core.core_tools.jwt_helper import SimpleAuth
from infirmary_admin_src.infirmary_common.infirmary_controller import IAsyncSessionBaseController, IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends, Path, Body
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.support.services import SupportBusinesses


class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''
    create_time: str = Body('', alias='createTime', title="create_time", description='创建时间')
    deleted_flag: bool = Body(False, alias='deletedFlag', title="deleted_flag", description='是否删除标记')
    update_time: str = Body('', alias='updateTime', title="update_time", description='更细时间')
    dict_key_id: int = Body(None, alias='dictKeyId', title="dict_key_id", description='权限类型')
    key_code: str = Body(None, alias='keyCode', title="key_code", description='权限类型')
    key_name: str = Body(None, alias='keyName', title="key_name", description='权限类型')
    remark: str = Body(None, alias='remark', title="remark", description='web权限标记')




class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 schema_param: XParam,
                 ):
        super().__init__(request=request)
        # 入参参数
        # 入参参数
        self.schema_param = schema_param


@RestControllerWithDepends()
class SupportDictKeyEditController(IController):

    def business_login(self):
        pass

        result = SupportBusinesses.edit_dict_key_singe(dict_key_id=self.schema_param.dict_key_id,
                                                     **self.schema_param.dict(exclude={'dict_key_id'}))
        if result:
            self.response_msg = '更新成功'
        else:
            self.response_ok = False
            self.response_msg = '更新失败'
            return None

        return None